<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <ul id="parent"><li>1</li><li>2</li><li>3</li></ul>
    <script>
        var childs = document.getElementById("parent").childNodes;//文本节点还是元素节点都获取
        var childEle = document.getElementById("parent").children;
        console.log(childs.length);
        console.log(childEle.length);
        for(var i=0;i<childs.length;i++){
            if(childs[i].nodeType==1){
                childs[i].style.color="red";
            }
        }
    </script>
</body>
</html>